package per.dj.testpro.netty;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import per.dj.testpro.entity.protocol.Message;

/**
 * 
 */
public class ProtocolEncoder extends MessageToByteEncoder<Message> {


	/* (non-Javadoc)
	 * @see io.netty.handler.codec.MessageToByteEncoder#encode(io.netty.channel.ChannelHandlerContext, java.lang.Object, io.netty.buffer.ByteBuf)
	 */
	@Override
	protected void encode(ChannelHandlerContext ctx, Message msg,
                          ByteBuf out) throws Exception {
		
		byte[] data = msg.WriteToBytes();		
		out.writeBytes(data);
		
	}
	

}
